import * as enum_types from "./base_type";
import * as unitApi from '@/service/system/unit'
import tempDataStore from './tempData'
/**
*@Author: QWP
*@Description: 基础数据的共享数据
*@Date 2023-08-14 14:58
*/

import { defineStore } from "pinia";

interface IAction {
  [key: string]: any
}

let tAction: IAction = {
  setDeptData(data: any[])  {
    this.deptData = data
  },
  setDeptUsers(data: any[]) {
    this.deptUsers = data
  },
  setModAndbill(data: any[]) {
    this.modAndbill = data;
  },
  setFileNoChar(data: any[]) {
    this.fileNoChars = data;
  },
  setUnitData(data: any[]) {
    this.unitData = data;
  },
};
let tState: IAction = {
  deptData: [],
  deptUsers: [],
  unitData: [],
  modAndbill: [],
  fileNoChars: [{label: '四川安信科创科技有限公司', value: 1}],
  ...tempDataStore
}
for(let key in enum_types) {
  tState[key] = [];
  tAction['set_'+key] = function(data: any[]) {
    this[key] = data
  };
}

const TSotre = {
  state: () => {
    return tState;
  },
  actions: tAction,
  persist: true
}

export const useBaseStore = defineStore('baseStore', TSotre)
